package com.xinghou.platform.dao.main.timer;

import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Random;

import javax.annotation.Resource;

import com.xinghou.timer.TimerService;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.spatial.SpatialStrategy;
import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.springframework.dao.DataAccessException;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
public class Timer {
    private static Boolean shareInfo = false;
    private static Boolean shareCard = false;
    private static Boolean exposure = false;
    private static Boolean store = false;
    /**
     * 男女 4,6分
     * 美迹每天50条（平均分布在8点到21点）
     * 晒卡每天每个一线城市5条（平均分布在8点到21点）
     * 蹭卡每天每个一线城市5条（平均分布在8点到21点[南京、深圳、苏州、天津、武汉、长沙、重庆这7个城市每天发布3条]）
     * <p/>
     * 上海 北京 深圳 广州 杭州 成µ都 重庆 南京 苏州 天津 武汉 福州 长沙
     * 310100 110100 120100 440300 440100 330100 510100 5000100 320100 320500 420100 350100 430100
     */
    @Resource
    private TimerService timerService;

    @Scheduled(cron = "0 3 18 ? * *")
    public void wzkShareInfoTimer() {
        if (!shareInfo) {
            shareInfo = true;
            timerService.wzkShareInfoTimer();
            shareInfo = false;

        }
    }

    @Scheduled(cron = "0 30 3 ? * *")
    public void wzkShareCardTimer() {
        if(!shareCard) {
            shareCard=true;
            timerService.wzkShareCardTimer();
            shareCard=false;
        }

    }

    @Scheduled(cron = "0 0 2 ? * *")
    public void wzkExposureTimer() {
        if(!exposure) {
            exposure=true;
            timerService.wzkExposureTimer();
            exposure=false;
        }
    }

    @Scheduled(cron = "0 0 11 ? * *")
    private void storeTimer() {
        if(!store) {
            store=true;
            timerService.storeTimer();
            store=false;
        }

    }

}
